/***********************************************
 This file is part of redia-bapps-main-ios.
 
 Copyright (c) 2015 Redia A/S
 
 Redia-bapps-main-ios is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 Redia-bapps-main-ios is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with redia-bapps-main-ios.  If not, see <http://www.gnu.org/licenses/>.
 
 *********************************************** */

//
//  BAReview.m
//  redia-bapps-ios
//
//  Created by Mads Darø Kristensen on 10/9/13.
//  Copyright (c) 2013 redia. All rights reserved.
//

#import "BAReview.h"
#import "JSONEncodingHelperMethods.h"

@implementation BAReview

+ (id)objectWithJSONObject:(NSDictionary *)jsonObj
{
    BAReview *obj = [[BAReview alloc] init];
    
    obj.url = [JSONEncodingHelperMethods parseStringWithKey:@"url" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.url);
    obj.title = [JSONEncodingHelperMethods parseStringWithKey:@"title" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.title);
    obj.reviewDescription = [JSONEncodingHelperMethods parseStringWithKey:@"description" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.reviewDescription);
    obj.text = [JSONEncodingHelperMethods parseStringWithKey:@"text" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.text);
    obj.creator = [JSONEncodingHelperMethods parseStringWithKey:@"creator" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.creator);
    obj.reviewCreator = [JSONEncodingHelperMethods parseStringWithKey:@"reviewCreator" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.reviewCreator);
    obj.source = [JSONEncodingHelperMethods parseStringWithKey:@"source" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.source);
    
    return obj;
}

- (NSDictionary *)toJSONObject
{
    EXPECT_OBJECT(NSString, self.url);
    EXPECT_OBJECT(NSString, self.title);
    EXPECT_OBJECT(NSString, self.reviewDescription);
    EXPECT_OBJECT(NSString, self.text);
    EXPECT_OBJECT(NSString, self.creator);
    EXPECT_OBJECT(NSString, self.reviewCreator);
    EXPECT_OBJECT(NSString, self.source);

    return @{
             @"url": self.url,
             @"title": self.title,
             @"description": self.reviewDescription,
             @"text": self.text,
             @"creator": self.creator,
             @"reviewCreator": self.reviewCreator,
             @"source": self.source
             };
}

@end
